<?php if ($this->_var['user_id'] == 0): ?>
		<a href="user.php?act=shepherd" class="ccc-btn auto-btn green-btn">请先登录</a>
	<?php else: ?>
		<?php if ($this->_var['gmtimes'] > $this->_var['sheep']['end_date']): ?>
			<a href="javascript:;" class="ccc-btn auto-btn">已过期</a>
		<?php else: ?> 
			<?php if ($this->_var['sheep']['start_date'] > $this->_var['gmtimes']): ?> 
				<a href="javascript:;"  class="ccc-btn auto-btn"><?php echo $this->_var['sheep']['kaishi_time']; ?>开始购买</a>
			<?php else: ?>
				<?php if ($this->_var['sheep']['sy_number'] == 0): ?>  
					<a href="javascript:;"  class="ccc-btn auto-btn">已售罄</a>
				<?php else: ?>	
					<?php if ($this->_var['sheep']['keyigomai'] > 0): ?> 
						<?php if ($this->_var['thissheep']): ?> 
							
							<a href="javascript:;" id="end_times" onclick="window.location.href='sheep.php?act=buy'" class="ccc-btn auto-btn green-btn" ><?php echo $this->_var['thissheep']['sytime']; ?></a>
							<div class="wk-tishi" ><?php echo $this->_var['sheep']['cart_count']; ?>只羊正在付款，如5分钟未完成支付会释放</div> 
							<script type="text/javascript" src="themes/view/js/countdown.js"></script>
							<script>
							/*引入倒计时*/
								new countdown().init('end_times');
							</script>
						<?php else: ?>
							
							<?php if ($this->_var['order']): ?>
							
								<a href="javascript:;" id="end_times" onclick="window.location.href='sheep.php?act=order&id=<?php echo $this->_var['order']['order_id']; ?>'" class="ccc-btn auto-btn green-btn" ><?php echo $this->_var['order']['sytime']; ?></a>
								<div class="wk-tishi" ><?php echo $this->_var['sheep']['cart_count']; ?>只羊正在付款，如5分钟未完成支付会释放</div> 
								<script type="text/javascript" src="themes/view/js/countdown.js"></script>
								<script>
								/*引入倒计时*/
									new countdown().init('end_times');
								</script>
							<?php else: ?>
							
							<a href="javascript:;" onclick="add_sheep(<?php echo $this->_var['id']; ?>)" class="ccc-btn auto-btn green-btn" >购买</a>
							<div class="wk-tishi" ><?php echo $this->_var['sheep']['cart_count']; ?>只羊正在付款，如5分钟未完成支付会释放</div> 
							<?php endif; ?>
						<?php endif; ?>
					<?php else: ?>
						<a href="javascript:;"  class="ccc-btn auto-btn">若有未付款，释放后可购买</a>
						<div class="wk-tishi" ><?php echo $this->_var['sheep']['cart_count']; ?>只羊正在付款，如5分钟未完成支付会释放</div> 
					<?php endif; ?> 
				<?php endif; ?> 
			<?php endif; ?>
		<?php endif; ?>
		
	<?php endif; ?>
<script>
var sytime = '<?php echo $this->_var['thissheep']['sytime']; ?>';
if(!sytime || sytime == 'undefined'){
	sytime = '<?php echo $this->_var['order']['sytime']; ?>';
}

function del(){
	if(sytime > 0){
		msgs('该订单已经提交，购买数量已被锁定');
		return false;
	}

	var num = document.getElementById("number");
	var n = parseInt(num.value);
	if(n-1<=0){
			alert("必须选择一只羊");
	}else{
		num.value = n-1;
	}
	changePrice();
}
function add(){
	if(sytime > 0){
		msgs('该订单已经提交，购买数量已被锁定');
		return false;
	}
	var num = document.getElementById("number");
	var n = parseInt(num.value);
	num.value = n+1;
	changePrice();
}
</script>